package cn.edu.gdpt.mobile0123456789hwh0408;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class MainActivity extends AppCompatActivity {
//一控件初始化：1、全局变量声明；2、定义initView()控件初始化方法；3、在onCreate()中调用initView()方法
    private RecyclerView rvMainPeople;
    private String[] names={"丁运生","方华高","朱云贵","邹辉","杨文","朱元元","周正文","张伟"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
//        设置列表布局方式为线性布局
        rvMainPeople.setLayoutManager(new LinearLayoutManager(this));
//      创建适配器对象
        PeopleAdapter adapter=new PeopleAdapter(names);
//        将适配器对象设置给RecyclerView控件
        rvMainPeople.setAdapter(adapter);
    }

    private void initView() {
        rvMainPeople = (RecyclerView) findViewById(R.id.rvMainPeople);
    }
}